package com.wy.projectssj.controller;

import com.wy.projectssj.domain.Role;
import com.wy.projectssj.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;

/**
 * @Author: wy
 * @Date:2019/8/29 9:10
 */
@Controller
@RequestMapping("/role")
public class RoleController {
      @Autowired
     private RoleService roleService;

     @RequestMapping("/addOne")
       public String addOne(){
          return "role-add";
       }
      @RequestMapping("/findAll")
      public String findAll(Model model){
          List<Role> roleAll = roleService.findAll();
                 model.addAttribute("roleList",roleAll);
                 return "role-list";
            }

            @RequestMapping("/save")
            public String save(Role role){
                int save = roleService.save(role);

                return "redirect:/role/findAll";
            }

            @RequestMapping("/delete")
            public String delete(String[] ids){
                int delete = roleService.deleteRole(ids);
                return "redirect:/role/findAll";
            }

}
